package org.mspring.mlog.schedule.job;

import org.mspring.mlog.core.ServiceFactory;
import org.mspring.mlog.service.bbs.ForumCatalogService;
import org.mspring.mlog.service.bbs.ForumService;
import org.mspring.mlog.service.stat.NewsStatService;
import org.mspring.mlog.service.stat.PostStatService;
import org.mspring.mlog.service.stat.TopicStatService;
import org.quartz.JobExecutionContext;

/**
 * 持久化统计信息
 * 
 * @author Gao Youbo
 * @since 2013年9月5日
 */
public class Statistics2DBJob extends BaseJob {

    @Override
    protected void nativeExecuteInternal(JobExecutionContext context) {
        // TODO Auto-generated method stub
        // 文章
        PostStatService postStatService = ServiceFactory.getBean(PostStatService.class);
        postStatService.views2DB();

        // 新闻
        NewsStatService newsStatService = ServiceFactory.getBean(NewsStatService.class);
        newsStatService.views2DB();

        // 帖子
        TopicStatService topicStatService = ServiceFactory.getBean(TopicStatService.class);
        topicStatService.views2DB();

        // 版块
        ForumService forumService = ServiceFactory.getBean(ForumService.class);
        forumService.updateForumTopics();
        forumService.updateForumReplys();

        // 版块分类
        ForumCatalogService forumCatalogService = ServiceFactory.getBean(ForumCatalogService.class);
        forumCatalogService.updateForumCatalogTopics();
        forumCatalogService.updateForumCatalogReplys();
    }
}
